#include<iostream>
#include<algorithm>
using namespace std;

const int N=2e5+10;
typedef long long ll;
ll arr[N];

int main()
{
	int n, c; cin>>n>>c;
	for(int i=1; i<=n; i++) cin>>arr[i];
	sort(arr+1, arr+1+n);
	ll ret=0;
	for(int i=2; i<=n; i++)
	{
		int a=arr[i], b=arr[i]-c;
		auto l=lower_bound(arr+1, arr+i, b);
		auto r=upper_bound(arr+1, arr+i, b);
		ret+=(r-l);
	}
	cout<<ret;
	return 0;
 } 
